<%@page import="model.environment.*"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<% 	PageViewInfo pvi = new PageViewInfo(); 
	pvi.setPageTitle("Administration - frontpage");
	
	// Sending a 403 if the user isn't an admin
	if (!Login.isAdministrator(session)) {
		response.sendError(403);
	}
	%>
<%@include file="../parts/header.jsp" %>
	<div class="content">
		<h1>Items</h1>
		<div style="width:700px;float:left;position:relative;height:40px;">
			<div>
				<h3><a href="editItem.jsp">Add item</a></h3>
			</div>
			<div style="position:absolute;top:0;right:0;">
				<h3><a href="showAllItemSales.jsp">Show all sales</a></h3>
			</div>
		</div>
			<%
			List<Item> items = Items.getItems();
			
			for (Item i : items) {%>	
				
			<div style="width:700px;border-top:1px solid black;float:left;">
				<div style="width:210px;border-right:1px dashed black;float:left;">
					<h3 style="text-align:left;">
						<a href='editItem.jsp?itemID=<%=i.getItemID()%>'>
							<%=i.getItemName()%>
						</a>
					</h3>
				</div>
				<div style="width:139px;border-right:1px dashed black;float:left;text-align:center;">
					<img src="<%=i.getThumbImageURL()%>" alt= "<%=i.getItemName()%>">
				</div>
				<div style="width:99px;border-right:1px dashed black;float:left;">
					<h3 style="text-align:center;"> Price: <%= i.getItemPrice()%></h3>
				</div>
				<div style="width:99px;border-right:1px dashed black;float:left;">
					<h3 style="text-align:center;">Stock: <%= i.getItemStock()%></h3>
				</div>
				<div style="width:99px;border-right:1px dashed black;float:left;">
					<h3 style="text-align:center;"><a href="showItemSales.jsp?itemID=<%=i.getItemID()%>"> Sales: <%= Sales.getNumberOfSales(i.getItemID())%></a></h3>
				</div>
			</div>

				<%
			}%>
 	</div>
<%@include file="../parts/footer.jsp" %>